// @Date         2021-11-10
// @Author       Aaron Zhang
// @Description   
// @FileName      provider.go   

package kernel

import (
	"zin/framework"
	"zin/framework/contract"
	"zin/framework/gin"
)

type ProviderKernel struct {
	HttpEngine *gin.Engine
}

func (p *ProviderKernel) Register(framework.Container) framework.NewInstance {
	return NewProviderServiceKernel
}

func (p *ProviderKernel) Boot(c framework.Container) error {
	if p.HttpEngine == nil {
		p.HttpEngine = gin.Default()
	}
	p.HttpEngine.SetContainer(c)
	return nil
}

func (p *ProviderKernel) IsDefer() bool {
	return false
}

func (p *ProviderKernel) Params(params map[string]interface{}) map[string]interface{} {
	params["engine"] = p.HttpEngine
	return params
}

func (p *ProviderKernel) Name() string {
	return contract.ProviderKeyKernel
}
